package com.singzi.leetcode.N200;

import java.util.Arrays;

public class T0189 {

    public static void main(String[] args) {
        Solution0189 solution0189 = new Solution0189();
        int []nums = {-1,-100,3,9};
        System.out.println(Arrays.toString(nums));
        solution0189.rotate(nums, 2);
        System.out.println(Arrays.toString(nums));
    }
}
class Solution0189 {
    public void rotate(int[] nums, int k) {


        int index = k%nums.length;
        System.out.println(index);
        if(index==0) return;

        int []temp = new int[nums.length];

        for (int i = 0; i < nums.length; i++) {
            temp[(i+index)%nums.length] = nums[i];

        }
        System.arraycopy(temp, 0, nums, 0, nums.length);


    }
}